home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / programr / textview / demo / utils.c < prev    next >
C/C++ Source or Header  |  1991-06-12  |  3KB  |  121 lines

  1. /*****************************************************************************
  2.  
  3.     utils.c
  4.     -------
  5.  
  6.     This module contains Useful Things
  7.  
  8.     This source is Copyright (c) Alan Phillips 1991. It may be freely used
  9.     and adapted for non-commercial applications. Commercial and ShareWare
  10.     authors should first obtain the written permission of the author.
  11.  
  12.     The source is edited with a tab size of 4.
  13.  
  14. *****************************************************************************/
  15.  
  16. #include    "stdhead.h"
  17. #include    <stdarg.h>
  18. #include    <ctype.h>
  19.  
  20.  
  21. /*****************************************************************************
  22.  
  23.     Local Variables
  24.     ---------------
  25.  
  26. *****************************************************************************/
  27.  
  28. static    HCURSOR    hSaveCursor,            /* cursor handle saved when hourglass
  29.                                         *  is being shown
  30.                                         */
  31.                 hHourGlass;                /* handle to hourglass cursor */
  32.  
  33. /*****************************************************************************
  34.  
  35.     message
  36.     -------
  37.  
  38.     Outputs a message in a tsk modal message box, with variable arguments
  39.  
  40.     reply = message(string,caption,type,...)
  41.  
  42.     int        reply;            Reply from MessageBox
  43.     LPSTR    string;            String to output, or NULL
  44.     LPSTR    caption;        Message box caption
  45.     WORD    type;            MessageBox wType argument. If NULL, the setting
  46.                             MB_ICONINFORMATION is used.
  47.     ...                        Optional arguments
  48.  
  49. *****************************************************************************/
  50.  
  51. int        message(LPSTR string,LPSTR caption,WORD type,...)
  52.  
  53. {
  54.     char    buffer[128];                /* work buffer */
  55.     va_list    arg_ptr;                    /* arg list pointer */
  56.  
  57.     /* Set up the argument list stuff */
  58.  
  59.     va_start(arg_ptr,type);
  60.  
  61.     /* And build the actual string to output */
  62.  
  63.     wvsprintf(buffer,string,arg_ptr);
  64.  
  65.     /* And display it, returning the result from MessageBox */
  66.  
  67.     return( MessageBox(NULL,
  68.                        buffer,
  69.                        caption,
  70.                        (type == NULL ) ? MB_ICONINFORMATION | MB_TASKMODAL
  71.                                           : type | MB_TASKMODAL) );
  72.  
  73.  
  74. }
  75.             
  76.  
  77. /*****************************************************************************
  78.  
  79.     hourglass_on
  80.     ------------
  81.  
  82.     Sets an hourglass cursor, getting window capture. There must be a call
  83.     of hourglass_off() to follow this.
  84.  
  85.     hourglass_on(hWnd)
  86.  
  87.     HWND    hWnd;                Window handle
  88.  
  89. *****************************************************************************/
  90.  
  91. void    hourglass_on(HWND hWnd)
  92.  
  93. {
  94.     hHourGlass    = LoadCursor(NULL,IDC_WAIT);
  95.     SetCapture(hWnd);
  96.     hSaveCursor    = SetCursor(hHourGlass);
  97. }
  98.  
  99.  
  100. /*****************************************************************************
  101.  
  102.     hourglass_off
  103.     -------------
  104.  
  105.     Restores the cursor from an hourglass to whatever it used to be, and
  106.     loses mouse capture. A previous call to hourglass_on() must have been
  107.     made.
  108.  
  109.     hourglass_off()
  110.  
  111. *****************************************************************************/
  112.  
  113. void    hourglass_off()
  114.  
  115. {
  116.     SetCursor(hSaveCursor);
  117.     ReleaseCapture();
  118. }
  119.  
  120.  
  121.